<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript">
        function checkAll(){
            //document.getElementsByTagName是按照指定标签名来进行查询并返回集合
            var elementsByTagName = document.getElementsByTagName("input");
            //类似于增强for循环
            for (var element of elementsByTagName) {
                element.checked = true;
            }
        }
    </script>
</head>
<body>
    兴趣爱好:
    <input type="checkbox" value="cpp">c++
    <input type="checkbox" value="java">java
    <input type="checkbox" value="js">js
    <br>
    <button onclick="checkAll()">全选</button>
</body>
</html>